#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1e8 + 10;
int p[N];
bool st[N];
int n, q;
int cnt = 0;
int main()
{
    cin >> n >> q;
    for (int i = 2; i <= n; i++)
    {
        if (!st[i])
        {
            p[++cnt] = i;
        }
        for (int j = 1; 1ll * i * p[j] <= n; j++)
        {
            st[i * p[j]] = true;
            if (i % p[j] == 0)
            {
                break;
            }
        }
    }
    while (q--)
    {
        int x = 0;
        cin >> x;
        cout << p[x] << endl;
    }
    return 0;
}